package com.ly.springsolrtest.springsolr.common;

import java.util.List;

/**
 * solr查询属性配置
 *
 * @param
 * @author linweijian
 * @date 2018/3/30 11:04
 * @return String keywords = "知道吗";
 * SolrQuery solrQuery = new SolrQuery();
 * solrQuery.setQuery("name:" + keywords + "or content:" + keywords); // 设置查询关键字
 * solrQuery.setHighlight(true); // 开启高亮
 * solrQuery.addHighlightField("name"); // 高亮字段
 * solrQuery.addHighlightField("content"); // 高亮字段
 * solrQuery.setHighlightSimplePre("<font color='red'>"); // 高亮单词的前缀
 * solrQuery.setHighlightSimplePost("</font>"); // 高亮单词的后缀
 */
public class SolrParams {
    private boolean enableHighlight;//是否开启高亮
    private String highlightSimplePre;//高亮单词前缀
    private String highlightSimplePost;//高亮单词后缀
    private List<String> highlightField;//设置开启高亮的字段
    //输出格式 xml, json, php, phps
    private String writerType;
    //查询语句
    private String queryString;
    /*hl.fragsize参数是摘要信息的长度。默认值是100，
    这个长度是出现关键字的位置向前移6个字符，再往后100个字符，取这一段文本。
    0表示不做摘要
    */
    private int highlightFragsize;

    public SolrParams() {

    }

    public boolean isEnableHighlight() {
        return enableHighlight;
    }

    public void setEnableHighlight(boolean enableHighlight) {
        this.enableHighlight = enableHighlight;
    }

    public String getHighlightSimplePre() {
        return highlightSimplePre;
    }

    public void setHighlightSimplePre(String highlightSimplePre) {
        this.highlightSimplePre = highlightSimplePre;
    }

    public String getHighlightSimplePost() {
        return highlightSimplePost;
    }

    public void setHighlightSimplePost(String highlightSimplePost) {
        this.highlightSimplePost = highlightSimplePost;
    }

    public List<String> getHighlightField() {
        return highlightField;
    }

    public void setHighlightField(List<String> highlightField) {
        this.highlightField = highlightField;
    }

    public String getWriterType() {
        return writerType;
    }

    public void setWriterType(String writerType) {
        this.writerType = writerType;
    }

    public String getQueryString() {
        return queryString;
    }

    public void setQueryString(String queryString) {
        this.queryString = queryString;
    }

    public int getHighlightFragsize() {
        return highlightFragsize;
    }

    public void setHighlightFragsize(int highlightFragsize) {
        this.highlightFragsize = highlightFragsize;
    }

    @Override
    public String toString() {
        return "SolrParams{" +
                "enableHighlight=" + enableHighlight +
                ", highlightSimplePre='" + highlightSimplePre + '\'' +
                ", highlightSimplePost='" + highlightSimplePost + '\'' +
                ", highlightField=" + highlightField +
                ", writerType='" + writerType + '\'' +
                ", queryString='" + queryString + '\'' +
                ", highlightFragsize=" + highlightFragsize +
                '}';
    }
}
